"use strict";
cc._RF.push(module, '0f9a9rJwXFIGJAPtwkypiMi', 'coliderlisten');
// Script/2048/coliderlisten.js

"use strict";

exports.__esModule = true;
exports.firstConcat = void 0;

var _common = require("../common");

var firstConcat = {};
exports.firstConcat = firstConcat;
cc.Class({
  "extends": cc.Component,
  properties: {
    prefabQiu: cc.Prefab,
    is_Deal: true,
    num: cc.Label,
    juicePrefab: cc.Prefab,
    //果汁
    // 得分音效资源
    scoreAudio: {
      "default": null,
      type: cc.AudioClip
    }
  },
  init: function init(data) {
    var is_anim = data.is_anim ? data.is_anim : false;
    this.DrawBall(data.num, this.node, is_anim);
  },
  DrawBall: function DrawBall(num, ballnode, is_anim) {
    var _this = this;

    if (is_anim === void 0) {
      is_anim = false;
    }

    return function (num) {
      var num = parseInt(num); // console.log("球的大小：",num);
      // console.log("球的属性：",ballnode);
      // console.log(num, G.maxNum)

      if (num > _common.G.maxNum) _common.G.maxNum = num; //小球赋值

      ballnode.getChildByName('num').getComponent(cc.Label).string = num;

      if (is_anim) {
        //播放动画
        // var anim = ballnode.getComponent(cc.Animation);
        // anim.play();
        // anim.on('finished',()=>{
        //     ballnode.setScale(G.BallArr[num]);
        // },this);
        cc.tween(_this.node) // 0s 时，node 的 scale 还是 1
        .to(0.03, {
          scale: _common.G.BallArr[num] * 1.4
        }).to(0.04, {
          scale: _common.G.BallArr[num] * 1.2
        }) // 1s 时，执行完第一个 action，scale 为 2
        .to(0.05, {
          scale: _common.G.BallArr[num]
        }) // 2s 时，执行完第二个 action，scale 为 3
        .start(); // 调用 start 开始执行 cc.tween
        //ballnode.setScale(G.BallArr[num]);
      } else {
        ballnode.setScale(_common.G.BallArr[num]);
      } //画图片


      var thenum = Math.log(num) / Math.log(2);
      cc.resources.load("img/planet_list/fruit", cc.SpriteAtlas, function (err, atlas) {
        ballnode.getComponent(cc.Sprite).spriteFrame = atlas.getSpriteFrame('fruit_' + thenum);
      });
    }(num);
  },
  onFinished: function onFinished() {},
  // use this for initialization
  onLoad: function onLoad() {
    // this.num.string = 2
    cc.director.getCollisionManager().enabled = true; // cc.resources.preload('img/planet_list/juice', cc.SpriteAtlas);

    cc.resources.preload('img/planet_list/fruit', cc.SpriteAtlas);
  },
  onCollisionEnter: function onCollisionEnter(other, self) {
    if (self.node && other.node) {
      var selfNum = self.node.getChildByName('num').getComponent(cc.Label);
      var otherNum = other.node.getChildByName('num').getComponent(cc.Label);
      var iswaterM = false;
      if (selfNum.string == 2048 || otherNum.string == 2048) iswaterM = true;

      if (selfNum.string === otherNum.string && selfNum.string != 0 && otherNum.string != 0) {
        self.node.emit('sameContact', self, other, selfNum.string * 2, iswaterM);
      } else {
        var mousemove = cc.find("Canvas/Mousemove");
        var line = cc.find("Canvas/line"); //const r = self.node.height*self.node.scale/2;//半径

        var qiu_y;

        if (self.node.y < 0) {
          qiu_y = mousemove.y - Math.abs(self.node.y); //G.maxHeight = G.maxHeight > line.y ? this.GameOver(G.maxHeight) : qiu_y;
        }
      }
    }
  },
  GameOver: function GameOver(max) {
    // console.log("mx:",max)
    var result = cc.find("Canvas/Result");
    setTimeout(function () {
      result.active = true;
    }, 600);
  }
});

cc._RF.pop();